str1= "123 98 234 23 345"

# 先将字符串分割成成list
list = str1.split(" ")

# 遍历列表,计算和
sum = 0
for n in  list:
    sum += int(n)     #n的类型是字符串,需要转成int
print(sum)